﻿package plugin.component
{
    import com.sh.game.util.*;
    import flash.display.*;
    import plugin.component.view.*;

    public class SimpleRoleManager extends Object
    {
        private var _realX:Number = 0;
        private var _realY:Number = 0;
        public var id:int = 0;
        public var moveType:int = 0;
        public var mine:Boolean = false;
        private var _container:Sprite;
        private var data:Object;
        private var role:RoleShow;

        public function SimpleRoleManager(param1:Object, param2:Sprite)
        {
            this.id = param1.id;
            this.data = param1;
            this._container = param2;
            this._container.mouseChildren = false;
            this._container.mouseEnabled = false;
            this.addRoleToView();
            return;
        }// end function

        public function addRoleToView() : void
        {
            var _loc_7:int = 0;
            var _loc_1:Object = null;
            if (this.data.hasOwnProperty("user"))
            {
                _loc_1 = this.data.user;
            }
            else
            {
                _loc_1 = this.data;
            }
            var _loc_2:* = _loc_1.arms;
            var _loc_3:* = _loc_1.wing;
            var _loc_4:* = new BooleanArray(_loc_1.ytshow);
            var _loc_5:* = new BooleanArray(_loc_1.ytshow).getValue(0);
            var _loc_6:* = ObjectUtil.clone(_loc_1.fashions);
            if (ObjectUtil.clone(_loc_1.fashions) != null)
            {
                _loc_7 = 1;
                while (_loc_7 <= 5)
                {
                    
                    if (_loc_4.getValue(_loc_7))
                    {
                        _loc_6[_loc_7] = 0;
                    }
                    _loc_7++;
                }
            }
            if (this.role == null)
            {
                this.role = new RoleShow(_loc_1.model, _loc_1.sex, _loc_2, _loc_3, _loc_6);
                this.role.mouseChildren = false;
                this.role.mouseEnabled = false;
                this.role.x = this.x;
                this.role.y = this.y;
                this._container.addChild(this.role);
            }
            else
            {
                this.role.updateshow(_loc_1.sex, _loc_2, _loc_3, _loc_6);
            }
            return;
        }// end function

        public function updateRoel(param1:Object) : void
        {
            this.data = param1;
            this.addRoleToView();
            return;
        }// end function

        public function removeRole(param1:Boolean = true) : void
        {
            if (this.role && this.role.parent)
            {
                this.role.parent.removeChild(this.role);
            }
            if (this.role && param1)
            {
                this.role.destroy();
                this.role = null;
            }
            return;
        }// end function

        public function set x(param1:Number) : void
        {
            this._realX = param1;
            return;
        }// end function

        public function get x() : Number
        {
            return this._realX;
        }// end function

        public function get y() : Number
        {
            return this._realY;
        }// end function

        public function set y(param1:Number) : void
        {
            this._realY = param1;
            return;
        }// end function

    }
}
